<script setup>
import { artGetChannelService } from '@/api/article'
import { ref } from 'vue'

defineProps({
  modelValue: {
    type: [Number, String]
  },
  width: {
    type: String
  }
})
const emit = defineEmits(['update:modelValue'])

const channelList = ref([])
const getChannelList = async() => {
  const res = await artGetChannelService()
  channelList.value = res.data
  console.log(channelList.value)
}
getChannelList()
</script>
<template>
   <!-- label 是展示给用户看的 value 是提交给后台的id -->
    <!-- 与父组件的v-model进行双向绑定 -->
   <el-select :style="{width}" :modelValue="modelValue"  @update:modelValue="emit('update:modelValue', $event)">
     <el-option v-for="channel in channelList" :key="channel.id" :label="channel.cate_name" :value="channel.id"></el-option>
   </el-select>
</template>